import java.util.ArrayList;
import java.util.LinkedList;

public class arraylist_linkedlist {
    public static void main(String[] args) {
        for (int num = 5000000; num < 1000 * 10000; num += 1000000) {
            ArrayList alist = new ArrayList();
            long startTime = System.currentTimeMillis();
            for (int i = 0; i < num; i++) {
                alist.add(i);
            }
            long endTime = System.currentTimeMillis();
            System.out.println("num=" + num + ",ArrayList：" + (endTime - startTime) + "ms");

            LinkedList llist = new LinkedList();
            long startTime1 = System.currentTimeMillis();
            for (int i = 0; i < num; i++) {
                llist.add(i);
            }
            long endTime1 = System.currentTimeMillis();
            System.out.println("num=" + num + ",LinkedList：" + (endTime1 - startTime1) + "ms");
        }
    }
}